package ar.uade.edu.fain.ad.client.delegate.rmi.util;

import java.rmi.Remote;

import ar.uade.edu.fain.ad.client.delegate.AdministracionDelegate;
import ar.uade.edu.fain.ad.client.delegate.CajaServiceDelegate;
import ar.uade.edu.fain.ad.client.delegate.DelegateFactory;
import ar.uade.edu.fain.ad.client.delegate.EmpleadoServiceDelegate;
import ar.uade.edu.fain.ad.client.delegate.SalonServiceDelegate;
import ar.uade.edu.fain.ad.client.delegate.rmi.AdministracionSRVD;
import ar.uade.edu.fain.ad.client.delegate.rmi.CajaSRVD;
import ar.uade.edu.fain.ad.client.delegate.rmi.EmpleadoSRVD;
import ar.uade.edu.fain.ad.client.delegate.rmi.SalonSRVD;
import ar.uade.edu.fain.ad.common.remote.CajaServicioRemoto;
import ar.uade.edu.fain.ad.common.remote.EmpleadoServicioRemoto;
import ar.uade.edu.fain.ad.common.remote.SalonServicioRemoto;
import ar.uade.edu.fain.ad.common.remote.SwingProcessRemoto;

public class RMIDelegateFactory implements DelegateFactory {

	private String serverName;
	private Integer serverPort;

	public RMIDelegateFactory() {
		super();
	}

	public String getServerName() {
		return serverName;
	}

	public void setServerName(String serverName) {
		this.serverName = serverName;
	}

	public Integer getServerPort() {
		return serverPort;
	}

	public void setServerPort(Integer serverPort) {
		this.serverPort = serverPort;
	}

	protected <T extends Remote> ServiceLocator<T> createServiceLocator(
			final Class<T> clazz, final String serviceName) {
		return new ServiceLocator<T>(
				getServerName(), getServerPort(), serviceName);
	}

	/* (non-Javadoc)
	 * @see ar.uade.edu.fain.ad.client.delegate.rmi.util.DelegateFactory#createSalonDelegate()
	 */
	@Override
	public SalonServiceDelegate createSalonDelegate() {
		return new SalonSRVD(createServiceLocator(
				SalonServicioRemoto.class, "salon"));
	}

	/* (non-Javadoc)
	 * @see ar.uade.edu.fain.ad.client.delegate.rmi.util.DelegateFactory#createCajaDelegate()
	 */
	@Override
	public CajaServiceDelegate createCajaDelegate() {
		return new CajaSRVD(createServiceLocator(
				CajaServicioRemoto.class, "caja"));
	}
	
	/* (non-Javadoc)
	 * @see ar.uade.edu.fain.ad.client.delegate.rmi.util.DelegateFactory#createEmpleadoDelegate()
	 */
	@Override
	public EmpleadoServiceDelegate createEmpleadoDelegate() {
		return new EmpleadoSRVD(createServiceLocator(
				EmpleadoServicioRemoto.class, "empleado"));
	}

	@Override
	public AdministracionDelegate createAdministracionDelegate() {
		return new AdministracionSRVD(createServiceLocator(
				SwingProcessRemoto.class, "administracion"));
	}

}
